﻿using Sidvall.IO.Security;
using Sidvall.Net;
using Sidvall.Net.Mime;
using System.Threading;
using System.Threading.Tasks;

namespace Sidvall.IO
{
    public class NetFileSystemStrategyBase : INetFileSystemStrategy
    {
        #region Public Members

        #region GetHttpContent

        public virtual string GetHttpContent(ResourceType resource, FileSystemOperation action, object value)
        {
            if (value != null)
                return Sidvall.Serialization.SerializerManager.Current.SerializeObject(value);
            else
                return null;
        }

        #endregion
        #region GetHttpMethod

        public virtual HttpMethod GetHttpMethod(ResourceType resource, FileSystemOperation action, HttpMethod method)
        {
            return method;
        }

        #endregion
        #region GetHttpResponseType

        public virtual MediaType? GetHttpResponseType(ResourceType resource, FileSystemOperation action, MediaType? responseType)
        {
            return responseType;
        }

        #endregion
        #region GetHttpRequestAddress

        public virtual string GetHttpRequestAddress(ResourceType resource, FileSystemOperation action, Sidvall.Net.HttpMethod method, string storeId, string path)
        {
            return NetSystemContext.Current.GetWebAddress(null, resource, action, method, storeId, path);
        }

        #endregion

        #region FileExistsAsync

        public virtual Task<bool?> FileExistsAsync(string path, CancellationToken cancellationToken)
        {
            return Task.FromResult((bool?)null);
        }

        #endregion
        #region GetLengthAsync

        public virtual Task<long?> GetLengthAsync(string path, CancellationToken cancellationToken)
        {
            return Task.FromResult((long?)null);
        }

        #endregion

        #endregion
    }
}
